function [Z,y_tN,N] = getStartingValues(x,setupEPer)
% Obtaining information from setupEPer
yEx       = setupEPer.yEx;
yExx      = setupEPer.yExx;
yExxx     = setupEPer.yExxx;
yE4x      = setupEPer.yE4x;
xEx       = setupEPer.xEx;
xExx      = setupEPer.xExx;
xExxx     = setupEPer.xExxx;
xE4x      = setupEPer.xE4x;
ny        = setupEPer.ny;
nx        = setupEPer.nx;
mx        = setupEPer.mx;
Nmax      = setupEPer.Nmax;
Nmin      = setupEPer.Nmin;
maxDistSS = setupEPer.maxDistSS;
orderApp  = setupEPer.orderAppStart;


xE     = zeros(nx,Nmax);
yE     = zeros(ny,Nmax);
AA     = kron(x,x);
AAA    = kron(AA,x);
AAAA   = kron(AAA,x);
distSS = 100;
i      = 0;
while distSS > maxDistSS && i < Nmax 
  i = i + 1;
  yE(:,i) = reshape(yEx(:,i,:),ny,nx)*x;
  xE(:,i) = reshape(xEx(:,i,:),nx,nx)*x;
  if orderApp > 1
      yE(:,i) = yE(:,i) + 1/2*reshape(yExx(:,i,:,:),ny,nx^2)*AA;
      xE(:,i) = xE(:,i) + 1/2*reshape(xExx(:,i,:,:),nx,nx^2)*AA;
  end
  if orderApp > 2
      yE(:,i) = yE(:,i) + 1/6*reshape(yExxx(:,i,:,:,:),ny,nx^3)*AAA;
      xE(:,i) = xE(:,i) + 1/6*reshape(xExxx(:,i,:,:,:),nx,nx^3)*AAA;
  end
  if orderApp > 3
      yE(:,i) = yE(:,i) + 1/24*reshape(yE4x(:,i,:,:,:),ny,nx^4)*AAAA;
      xE(:,i) = xE(:,i) + 1/24*reshape(xE4x(:,i,:,:,:),nx,nx^4)*AAAA;
  end
  %distSS = max(abs([yE(:,i);xE(:,i)]));
  distSS = max(abs(yE(:,i)));
  if i < Nmin
      distSS = 100;
  end
end
N    = i;
Z    = [yE(1:ny,1:N); xE(1:mx,1:N)];
y_tN = yE(1:ny,N);
end


